package com.codi.bus.core.resultModel;

import com.alibaba.fastjson.annotation.JSONField;
import com.codi.base.util.BigDecimalUtil;
import com.codi.base.util.MoneyUtils;
import com.codi.bus.core.service.model.AssetFundModel;
import com.codi.bus.core.service.model.AssetPortfolioModel;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;

/**
 * 我的资产
 *
 * @author Shangdu Lin
 */
public class AssetsResult extends BaseResult {

    /**
     *
     */
    private static final long serialVersionUID = 1L;

    /**
     * 当日收益
     */
    private BigDecimal totalTodayIncome;

    public BigDecimal getTotalTodayIncome() {
        return this.totalTodayIncome;
    }

    public void setTotalTodayIncome(BigDecimal todayIncome) {
        this.totalTodayIncome = todayIncome;
    }

    public String getTotalTodayIncomeString() {
        BigDecimal walletIncome = new BigDecimal(0);
        if (wallet != null) {
            walletIncome = BigDecimalUtil
                .ConvertToBigDecimal(MoneyUtils.unformatMoney(wallet.getTotalTodayIncomeString()));
        }

        BigDecimal fundIncome = new BigDecimal(0);
        if (fund != null) {
            fundIncome = BigDecimalUtil.ConvertToBigDecimal(MoneyUtils.unformatMoney(fund.getTotalTodayIncomeString()));
        }

        return MoneyUtils.formatMoney(MoneyUtils.add(walletIncome, fundIncome));
    }

    @Getter
    @Setter
    private BigDecimal totalShareIncome;

    public String getTotalShareIncomeString() {
        return MoneyUtils.formatMoney(totalShareIncome);
    }

    @Getter
    @Setter
    private BigDecimal totalAccumIncome;

    public String getTotalAccumIncomeString() {
        return MoneyUtils.formatMoney(totalAccumIncome);
    }
    /**
     * 总资产
     */
    private BigDecimal totalWorthValue;

    public BigDecimal getTotalWorthValue() {
        return this.totalWorthValue;
    }

    public void setTotalWorthValue(BigDecimal totalWorthValue) {
        this.totalWorthValue = totalWorthValue;
    }

    public String getTotalWorthValueString() {
//        BigDecimal walletWorth = new BigDecimal(0);
//        if (wallet != null) {
//            walletWorth = BigDecimalUtil
//                .ConvertToBigDecimal(MoneyUtils.unformatMoney(wallet.getTotalWorthValueString()));
//        }
//
//        BigDecimal fundWorth = new BigDecimal(0);
//        if (fund != null) {
//            fundWorth = BigDecimalUtil.ConvertToBigDecimal(MoneyUtils.unformatMoney(fund.getTotalWorthValueString()));
//        }
//        return MoneyUtils.formatMoney(MoneyUtils.add(walletWorth, fundWorth));
        return MoneyUtils.formatMoney(totalWorthValue);
    }


    private BigDecimal totalInTransitAmount;

    public BigDecimal getTotalInTransitAmount() {
        return totalInTransitAmount;
    }

    public void setTotalInTransitAmount(BigDecimal totalInTransitAmount) {
        this.totalInTransitAmount = totalInTransitAmount;
    }
    public String getTotalInTransitAmountString() {
        if (totalInTransitAmount != null && totalInTransitAmount.doubleValue() != 0.00 ) {
            StringBuffer sb = new StringBuffer();
            sb.append("买入待确认");
            sb.append(MoneyUtils.formatMoney(totalInTransitAmount));
            sb.append("元");
            return sb.toString();
        }
        return "";
    }

    /**
     * 在途总笔数
     *
     * 目前没有区分 单只基金和组合基金的在途  所以笔数也显示在这里
     */
    @JSONField(serialize = false)
    private Integer totalInTransitNum;

    @JSONField(serialize = false)
    public Integer getTotalInTransitNum() {
        return totalInTransitNum;
    }

    public void setTotalInTransitNum(Integer inTransitNum) {
        this.totalInTransitNum = inTransitNum;
    }

    public String getTotalInTransitNumString() {
        if (totalInTransitNum != null && totalInTransitNum != 0) {
            StringBuffer sb = new StringBuffer();
            sb.append("有");
            sb.append(totalInTransitNum);
            sb.append("笔买入确认中");
            return sb.toString();
        }
        return "";
    }



    /**
     * 基金
     */
    private AssetFundModel fund;

    public void setFund(AssetFundModel fund) {
        this.fund = fund;
    }

    public AssetFundModel getFund() {
        return this.fund;
    }

    /**
     * 零钱包
     */
    private AssetFundModel wallet;

    public void setWallet(AssetFundModel wallet) {
        this.wallet = wallet;
    }

    public AssetFundModel getWallet() {
        return this.wallet;
    }

    /**
     * 组合
     */
    private AssetPortfolioModel portfolios;

    public void setPortfolios(AssetPortfolioModel portfolios){ this.portfolios = portfolios; }

    public AssetPortfolioModel getPortfolios(){ return this.portfolios; }


    @Setter
    @Getter
    private Boolean isChinaTax;

}
